package nsu.edu.zsq.controller.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;

import nsu.edu.zsq.bean.Course;
import nsu.edu.zsq.bean.Student;
import nsu.edu.zsq.common.JsonData;
import nsu.edu.zsq.param.PageQuery;
import nsu.edu.zsq.service.sys.RetakeCourseService;

/** 
* Description: 重修信息管理的controller类<br>
*/

@RequestMapping("/sys/retakeCourse")
@Controller
public class RetakeCourseController {
    
    @Autowired
    private RetakeCourseService retakeCourseService;

    
    /**
     * 获取重修课程列表
     * @param pageQuery 分页信息
     * @return JsonData
     */
    @RequestMapping("/listRetakeCourse")
    @ResponseBody
    public JsonData listRetakeCourse(PageQuery pageQuery) {
        PageInfo<Course> listRetakeCourse = retakeCourseService.listRetakeCourseWithPage(pageQuery);
        return JsonData.success(listRetakeCourse);
    }
    
    /**
     * 跳转到查看学生页面
     * @param courseNo 课程代码
     * @param model
     * @return String manager/exam/retake/retakeCourse_student.html
     */
    @RequestMapping("/ToRetakeCourse_student")
    public String ToRetakeCourse_student(@RequestParam("courseNo")String courseNo, Model model) {
        model.addAttribute("courseNo", courseNo);
        return "manager/exam/retake/retakeCourse_student.html";
    }
    
    /**
     * 通过重修课程代码获取重修学生
     * @param courseNo 课程代码
     * @param pageQuery 分页信息
     * @return JsonData
     */
    @RequestMapping("/listRetakeStudent")
    @ResponseBody
    public JsonData  listRetakeStudent(@RequestParam("courseNo")String courseNo, PageQuery pageQuery) {
        PageInfo<Student> listRetakeStudent = retakeCourseService.listRetakeStudent(courseNo, pageQuery);
        return JsonData.success(listRetakeStudent);
    }
}
